# Maintainer: Andy Postnikov <apostnikov@gmail.com>
pkgname=php81-pecl-jsmin
_extname=jsmin
pkgver=3.0.0
pkgrel=0
_jqver=2.1.3
pkgdesc="PHP 8.1 extension for minifying JavaScript - PECL"
url="https://pecl.php.net/package/jsmin"
arch="all !ppc64le" # test fails on builder
license="PHP-3.01"
_phpv=81
_php=php$_phpv
depends="$_php-common"
makedepends="$_php-dev"
source="php-pecl-$_extname-$pkgver.tgz::https://pecl.php.net/get/$_extname-$pkgver.tgz
	jquery-$_jqver.js::https://github.com/sqmk/pecl-jsmin/raw/v$pkgver/tests/data/jquery-$_jqver.js
	fix-php8.patch
	fix-tests.patch
	"
builddir="$srcdir/$_extname-$pkgver"

build() {
	phpize$_phpv
	./configure --prefix=/usr --with-php-config=/usr/bin/php-config$_phpv
	make
}

check() {
	mkdir -p tests/data
	cp "$srcdir"/jquery-$_jqver.js tests/data/

	case "$CARCH" in
		aarch64|x86_64) rm tests/call-multiple-times.phpt ;;
	esac
	$_php -dextension=modules/$_extname.so --ri $_extname
	make NO_INTERACTION=1 REPORT_EXIT_STATUS=1 test TESTS='--show-diff '
}

package() {
	make INSTALL_ROOT="$pkgdir" install
	local _confdir="$pkgdir"/etc/$_php/conf.d
	install -d $_confdir
	echo "extension=$_extname" > $_confdir/$_extname.ini
}

sha512sums="
a465ae024a49bb8ac20463efc6b2546021806c2c43053f42c7ebfea4924b9b647b6e7c0c673102e12ecd8b693666441dc07203edef216eee958fa62f73056ea6  php-pecl-jsmin-3.0.0.tgz
b8eb1a740c63feaab8ac24d87f39f4cfe263694c972f4978b9f0e3092f912a722596fd094dd637d22f03816617e13210bf11fad9a545dbb0423dc821c827081e  jquery-2.1.3.js
72f4ea4aad457d1a557e05ff8457a689ea75419e414b0893c2bdf5d7216d70b7c26a4993e3c9fa97de3409d080b3cf2a5bd2f0c4b050854c02f08ac592da1f85  fix-php8.patch
e44a2615d98d786e0188d3880b41f267dab2fa215fb17cd37b17f8cc499bee7dd9e4fe1def4707dbd6769fa40ba2dbf7895ba3544db427a7d851f69a515fa83c  fix-tests.patch
"
